package cn.poco.pepsi.service.impl;

import java.io.InputStream;
import java.util.ArrayList;

import android.util.Log;
import cn.poco.pepsi.bean.Mail;
import cn.poco.pepsi.bean.MailVote;
import cn.poco.pepsi.bean.RemindSum;
import cn.poco.pepsi.util.UrlConnectionUtil;
import cn.poco.pepsi.util.UrlMatchUtil;
import cn.poco.pepsi.util.xmlpared.MailVoteXmlparse;
import cn.poco.pepsi.util.xmlpared.MailXmlparse;
import cn.poco.pepsi.util.xmlpared.RemindSumXmlparse;


public class RemindImpl {
	// ֪ͨ
	public final static String GET_REMINDVote_PATH = "http://img-m.poco.cn/mypoco/mtmpfile/MobileAPI/Message/food_vote_notice.php?uid=#a&s=#b&l=#c";
	public final static String GET_REMINDFollow_PATH = "http://img-m.poco.cn/mypoco/mtmpfile/MobileAPI/Message/friend_request.php?uid=#a&s=#b&l=#c";
	public final static String GET_REMINDSystem_PATH = "http://img-m.poco.cn/mypoco/mtmpfile/MobileAPI/Message/system_notice.php?uid=#a&s=#b&l=#c";
	public final static String GET_REMINDSum_PATH = "http://img-m.poco.cn/mypoco/mtmpfile/MobileAPI/Message/food_unread_num.php?uid=#a";

	public ArrayList<Mail> getRemainSystem(String uid, int s, int l) throws Exception {
		String path = GET_REMINDSystem_PATH.replace("#a", String.valueOf(uid)).replace("#b", String.valueOf(s))
				.replace("#c", String.valueOf(l));
		path = UrlMatchUtil.matchUrl(path);
		Log.i("impl", path);
		InputStream iStream = UrlConnectionUtil.getRequest(path);
		return MailXmlparse.getXml(iStream);
	}

	public ArrayList<Mail> getRemainFollow(String uid, int s, int l) throws Exception {
		String path = GET_REMINDFollow_PATH.replace("#a", String.valueOf(uid)).replace("#b", String.valueOf(s))
				.replace("#c", String.valueOf(l));
		path = UrlMatchUtil.matchUrl(path);
		Log.i("impl", path);
		InputStream iStream = UrlConnectionUtil.getRequest(path);
		return MailXmlparse.getXml(iStream);
	}

	public ArrayList<MailVote> getRemainVote(String uid, int s, int l) throws Exception {
		String path = GET_REMINDVote_PATH.replace("#a", String.valueOf(uid)).replace("#b", String.valueOf(s))
				.replace("#c", String.valueOf(l));
		path = UrlMatchUtil.matchUrl(path);
		Log.i("impl", path);
		InputStream iStream = UrlConnectionUtil.getRequest(path);
		return MailVoteXmlparse.getXml(iStream);
	}

	public RemindSum getRemaindSum(String uid) throws Exception {
		String path = GET_REMINDSum_PATH.replace("#a", String.valueOf(uid));
		path = UrlMatchUtil.matchUrl(path);
		Log.i("impl", path);
		InputStream iStream = UrlConnectionUtil.getRequest(path);
		return RemindSumXmlparse.getXml(iStream);
	}

}
